// 导入vue-router
import { createRouter, createWebHistory } from 'vue-router'

// 导入页面
import LoginOrRegisterVue from '@/views/LoginOrRegister.vue'
import HomeVue from '@/views/Home.vue'


// 定义路由关系
const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    component: HomeVue,
    children: [
      {
        path: '',
        redirect: '/home/front',
      }, {
        path: '/home/front',
        component: () => import('@/views/FrontPage.vue'),
      }, {
        path: '/home/details',
        component: () => import('@/views/Details.vue'),
      },
      {
        path: '/home/goods',
        component: () => import('@/views/HomeGoods.vue'),
      },
      {
        path: '/home/purchase',
        component: () => import('@/views/HomePurchase.vue'),
      },
      {
        path: '/home/purchaseDetails',
        component: () => import('@/views/purchaseDetails.vue'),
      },
      {
        path: '/home/knowledge',
        component: () => import('@/views/HomeKnowledge.vue'),
      },
      {
        path: '/home/knowledgeDetail',
        component: () => import('@/views/knowledgeDetail.vue'),
      },
      {
        path: '/home/guide',
        component: () => import('@/views/HomeGuide.vue'),
      },
      {
        path: '/home/guideDetail',
        component: () => import('@/views/guideDetail.vue'),
      },
      {
        path: '/home/allExpert',
        component: () => import('@/views/AllExpert.vue'),
      },
      {
        path: '/home/question',
        component: () => import('@/views/Question.vue'),
      },
      {
        path: '/home/appointment',
        component: () => import('@/views/Appointment.vue'),
      },
      {
        path: '/home/shopcart',
        component: () => import('@/views/ShopCart.vue'),
      },
      {
        path: '/home/smartMatch',
        component: () => import('@/views/SmartMatch.vue')
      },
      {
        path: '/home/financing',
        component: () => import('@/views/Financing.vue')
      },
      {
        path: '/home/financingDetails',
        name: 'financingDetails',
        component: () => import('@/views/FinancingDetails.vue')
      },
      {
        path: 'aboutUs',
        component: () => import('@/views/AboutUs.vue')
      },
      {
        path: '/home/user',
        component: () => import('@/views/User.vue'),
        children: [
          {
            path: '',
            redirect: '/home/user/userinfo'
          },
          {
            path: '/home/user/userinfo',
            component: () => import('@/views/UserInfo.vue')
          },
          {
            path: '/home/user/useraddress',
            component: () => import('@/views/UserAddress.vue')
          },
          {
            path: '/home/user/userpassword',
            component: () => import('@/views/UserPassword.vue')
          }
        ]
      }
    ]
  },
  {
    path: '/LoginOrRegister/:type',
    name: 'LoginOrRegister',
    component: LoginOrRegisterVue,
  }
]
// 创建路由实例
const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router

